﻿using System;
using System.Collections.Generic;
using System.Windows.Input;

namespace OpenLS.Drawing.UI.Internals
{
    abstract class ShapeFillFormatterBase: ShapeFormatter
    {
        protected ShapeFillFormatterBase(IShape model)
            : base(model)
        {
        }

        public bool IsAutomatic { get { return GetFillType() == null; } }
        public bool IsSolid { get { return GetFillType() == typeof (SolidColorFillProperties); } }
        public bool IsGradient { get { return GetFillType() == typeof (GradientFillProperties); } }
        public bool IsNone { get { return GetFillType() == typeof(NoFillProperties); } }
        public bool IsPictureOrTexctureFill { get { return GetFillType() == typeof(PatternFillProperties); } }
        public ICommand SetNoFillCommand { get { return new DelegateCommand(() => SetFill( new NoFillProperties())); } }
        public ICommand SetAutomaticFillCommand { get { return new DelegateCommand(() => SetFill(null) ); } }

        public ICommand SetGradientFillCommand
        {
            get
            {
                return new DelegateCommand((param) =>
                                           SetFill(new GradientFillProperties()));
            }
        }

        public ICommand SetSolidFillCommand
        {
            get
            {
                return new DelegateCommand((param) =>
                                           SetFill( new SolidColorFillProperties((ColorBase)param)));
            }
        }

        public abstract ColorBase SelectedColor { get; set; }

        public IEnumerable<ColorBase> Colors
        {
            get { return ColorManager.UIColors; }
        }

        protected abstract Type GetFillType();
        protected abstract void SetFill (LineFillProperties lineFillProperties);
    }
}